import { Injectable, UploadedFile, } from '@nestjs/common';

@Injectable()
export class UploadService {
 async uploadFile(file: Express.Multer.File, req): Promise<any> {
    let ip = req.ip
    if (ip.indexOf('::ffff:') !== -1)
    {
        ip = ip.substring(7)
    }

    const temp = {
        fullPath:`http://${ip}:3000/uploads/${file.filename}`,
        relPath:`/uploads/${file.filename}`,
        fileName: file.filename
    }
    return temp;
  }
//   async uploadMultipleFiles(@UploadedFile() files) {
//     const response = [];
//     files.forEach((file) => {
//       const fileReponse = {
//         originalname: file.originalname,
//         filename: file.filename,
//       };
//       response.push(fileReponse);
//     });

//     return response;
//   }
}
